package com.ruoyi.web.controller.ydz;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.DiseaseTarget;
import com.ruoyi.web.service.IDiseaseTargetService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 疾病靶点Controller
 * 
 * @author drx
 * @date 2025-05-12
 */
@Controller
@RequestMapping("/ydz/diseaseTarget")
@Api(tags = "疾病靶点")
public class DiseaseTargetController extends BaseController
{
    private String prefix = "ydz/diseaseTarget";

    @Autowired
    private IDiseaseTargetService diseaseTargetService;

    @RequiresPermissions("ydz:diseaseTarget:view")
    @GetMapping()
    public String diseaseTarget()
    {
        return prefix + "/diseaseTarget";
    }

    /**
     * 查询疾病靶点列表
     */
    @RequiresPermissions("ydz:diseaseTarget:list")
    @PostMapping("/list")
    @ResponseBody
    @ApiOperation("查询疾病靶点列表")
    public TableDataInfo list(  DiseaseTarget diseaseTarget)
    {
        startPage();
        List<DiseaseTarget> list = diseaseTargetService.selectDiseaseTargetList(diseaseTarget);
        return getDataTable(list);
    }

    /**
     * 导出疾病靶点列表
     */
    @RequiresPermissions("ydz:diseaseTarget:export")
    @Log(title = "疾病靶点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    @ApiOperation("导出疾病靶点列表")
    public AjaxResult export(DiseaseTarget diseaseTarget)
    {
        List<DiseaseTarget> list = diseaseTargetService.selectDiseaseTargetList(diseaseTarget);
        ExcelUtil<DiseaseTarget> util = new ExcelUtil<DiseaseTarget>(DiseaseTarget.class);
        return util.exportExcel(list, "疾病靶点数据");
    }

    /**
     * 新增疾病靶点
     */
    @GetMapping("/add")
    @ApiOperation("新增疾病靶点")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存疾病靶点
     */
    @ApiOperation("新增保存疾病靶点")
    @RequiresPermissions("ydz:diseaseTarget:add")
    @Log(title = "疾病靶点", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DiseaseTarget diseaseTarget)
    {
        return toAjax(diseaseTargetService.insertDiseaseTarget(diseaseTarget));
    }

    /**
     * 修改疾病靶点
     */
    @ApiOperation("修改疾病靶点")
    @RequiresPermissions("ydz:diseaseTarget:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        DiseaseTarget diseaseTarget = diseaseTargetService.selectDiseaseTargetById(id);
        mmap.put("diseaseTarget", diseaseTarget);
        return prefix + "/edit";
    }

    /**
     * 修改保存疾病靶点
     */
    @ApiOperation("修改保存疾病靶点")
    @RequiresPermissions("ydz:diseaseTarget:edit")
    @Log(title = "疾病靶点", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DiseaseTarget diseaseTarget)
    {
        return toAjax(diseaseTargetService.updateDiseaseTarget(diseaseTarget));
    }

    /**
     * 删除疾病靶点
     */
    @ApiOperation("删除疾病靶点")
    @RequiresPermissions("ydz:diseaseTarget:remove")
    @Log(title = "疾病靶点", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(diseaseTargetService.deleteDiseaseTargetByIds(ids));
    }
}
